﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using interpreter_base;
using System.Collections.Specialized;
using Silmoon;
using System.Windows.Forms;

namespace smi
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length != 0)
            {
                NameValueCollection parameters = Silmoon.Configure.NameValueReader.ReadFromArrayStringToNameValue(Environment.GetCommandLineArgs(), ":");
                string file = args[0] != Path.GetFileName(args[0]) ? args[0] : Application.StartupPath + "/" + args[0];
                if (File.Exists(file))
                {
                    string[] fileLine = File.ReadAllLines(file);
                    Compiler compiler = new Compiler();
                    compiler.OnCompileUnknownScriptLine += new CompileUnknownScriptLineHandler(compiler_OnCompileUnknownScriptLine);
                    compiler.Compile(fileLine);
                }
                else
                    Console.WriteLine("File not found:" + file);
            }
        }

        static void compiler_OnCompileUnknownScriptLine(Compiler comparer, string line, string[] spaceSplitArray)
        {
            switch (spaceSplitArray[0])
            {
                case "add":
                    //Console.WriteLine("add:" + comparer.cEnv.GetValue(spaceSplitArray[1]));
                    break;
                default:
                    break;
            }
        }
    }
}
